LexicographicalCompare Generic Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Performs a lexicographical comparison of two sequences of values, using a supplied comparison delegate. A lexicographical comparison compares corresponding pairs of elements from two sequences in order. If the first element of sequence1 is less than the first element of sequence2, then the comparison ends and the first sequence is lexicographically less than the second. If the first elements of each sequence are equal, then the comparison proceeds to the second element of each sequence. If one sequence is shorter than the other, but corresponding elements are all equal, then the shorter sequence is considered less than the longer one.

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public static int LexicographicalCompare<T>(
	IEnumerable<T> sequence1,
	IEnumerable<T> sequence2,
	Comparison<T> comparison
)
Visual Basic (Declaration)
Public Shared Function LexicographicalCompare(Of T) ( _
	sequence1 As IEnumerable(Of T), _
	sequence2 As IEnumerable(Of T), _
	comparison As Comparison(Of T) _
) As Integer
Visual C++
public:
generic<typename T>
static int LexicographicalCompare (
	IEnumerable<T>^ sequence1, 
	IEnumerable<T>^ sequence2, 
	Comparison<T>^ comparison
)

Parameters

sequence1
IEnumerable<(Of <T>)>
The first sequence to compare.
sequence2
IEnumerable<(Of <T>)>
The second sequence to compare.
comparison
Comparison<(Of <T>)>
The IComparison<T> delegate to compare items. Only the Compare member function of this interface is called.

Return Value

Less than zero if sequence1 is lexicographically less than sequence2. Greater than zero if sequence1 is lexicographically greater than sequence2. Zero if sequence1 is equal to sequence2.

Type Parameters

T
Types of items to compare.

See Also